using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebFoundation.Data;
using MHI.InspectionManager.Interfaces; 

namespace MHI.InspectionManager.Data
{
	/// <summary>
	/// DevSparepartT,table entity:dev_sparepart_t 
	/// </summary>
	internal class DevSparepartTWritingDAO : WritableDAO<DevSparepartT> 
	{
		protected static DbManager _dbManager = DbManager.FromConfig("DefaultConnection");

		public DevSparepartTWritingDAO()
		: base(_dbManager)
		{
		}

		public DevSparepartTWritingDAO(DbManager db)
		: base(db)
		{
			_dbManager = db;
		}

		/// <summary>
		/// 增加一行DevSparepartT,table entity:dev_sparepart_t信息 
		/// </summary>
		/// <returns></returns>
		public bool AddDevSparepartT(DevSparepartT item)
		{
			this.Add(item);
			return true;
		}

		/// <summary>
		/// 增加多行DevSparepartT,table entity:dev_sparepart_t信息 
		/// </summary>
		/// <returns></returns>
		public bool AddDevSparepartTs(DevSparepartT[] items)
		{
			this.Add(items);
			return true;
		}

		/// <summary>
		/// 更新一行DevSparepartT,table entity:dev_sparepart_t信息 
		/// </summary>
		/// <returns></returns>
		public bool UpdateDevSparepartT(DevSparepartT item)
		{
			bool bOK = this.Update(item);
			return bOK;
		}

		/// <summary>
		///  更新多行DevSparepartT,table entity:dev_sparepart_t信息 
		/// </summary>
		/// <returns></returns>
		public bool UpdateDevSparepartTs(DevSparepartT[] items)
		{
			bool bOK = this.Update(items);
			return bOK;
		}

		/// <summary>
		/// 删除一行DevSparepartT,table entity:dev_sparepart_t信息 
		/// </summary>
		/// <returns></returns>
		public bool DeleteDevSparepartT(DevSparepartT item)
		{
			bool bOK = this.Delete(item);
			return bOK;
		}

		/// <summary>
		///  删除多行DevSparepartT,table entity:dev_sparepart_t信息 
		/// </summary>
		/// <returns></returns>
		public bool DeleteDevSparepartTs(DevSparepartT[] items)
		{
			bool bOK = this.Delete(items);
			return bOK;
		}

		/// <summary>
		///  根据ids，删除多行DevSparepartT,table entity:dev_sparepart_t信息 
		/// </summary>
		/// <returns></returns>
		public bool DeleteDevSparepartTByIds(int[] ids)
		{
			for (int i = 0; i < ids.Length; i++)
			{
				DynamicalBatchExcutor<DevSparepartT> excutor = new DynamicalBatchExcutor<DevSparepartT>(this.DBManager);
				excutor.Query().Filter().Eq(r => r.Id, ids[i]);
				excutor.BatchDelete(this.Transaction, _TimeOut);
			}
			return true;
		}

	}
}
